package com.banggood.upms.common.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * @author XuChuangFeng
 * @date 2017/7/10
 */
public enum StatusEnum implements BaseEnum {
    INACTIVE(0), ACTIVE(1);

    private int value;
    private static Map<Integer, StatusEnum> valueMap = new HashMap<>();

    static {
        for(StatusEnum status : StatusEnum.values()) {
            valueMap.put(status.value, status);
        }
    }

    StatusEnum(int value) {
        this.value = value;
    }

    @Override
    public int getValue() {
        return value;
    }

    public static StatusEnum getByValue(int value) {
        StatusEnum result = valueMap.get(value);
        if(result == null) {
            throw new IllegalArgumentException("No element matches " + value);
        }
        return result;
    }
}
